<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;

class UserWallet extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->decimal('money_wallet', 10, 2)->after('money_discount')->comment('钱包');
            $table->decimal('money_wallet_red', 10, 2)->after('money_discount')->comment('钱包分红');
        });
        
        Db::table('config')->insert([
            'name'  => 'money_wallet_red', 
            'value' => 0.055,
            'content' => '钱包每日分红比例'
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('money_wallet');
            $table->dropColumn('money_wallet_red');
        });
        
        Db::table('config')->where('name', 'money_wallet_red')->delete();
    }
}
